/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package generated_entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author aav
 */
@Entity
@Table(name = "CURRENCIES")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Currencies.findAll", query = "SELECT c FROM Currencies c"),
    @NamedQuery(name = "Currencies.findByCurrencyId", query = "SELECT c FROM Currencies c WHERE c.currencyId = :currencyId"),
    @NamedQuery(name = "Currencies.findByCurrencyIsoCode", query = "SELECT c FROM Currencies c WHERE c.currencyIsoCode = :currencyIsoCode"),
    @NamedQuery(name = "Currencies.findByCurrencySign", query = "SELECT c FROM Currencies c WHERE c.currencySign = :currencySign"),
    @NamedQuery(name = "Currencies.findByCurrencyName", query = "SELECT c FROM Currencies c WHERE c.currencyName = :currencyName")})
public class Currencies implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @Column(name = "CURRENCY_ID", nullable = false, precision = 0, scale = -127)
    private BigDecimal currencyId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "CURRENCY_ISO_CODE", nullable = false, length = 3)
    private String currencyIsoCode;
    @Size(max = 16)
    @Column(name = "CURRENCY_SIGN", length = 16)
    private String currencySign;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "CURRENCY_NAME", nullable = false, length = 32)
    private String currencyName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "currencies")
    private Collection<Rates> ratesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "currencyId")
    private Collection<Templates> templatesCollection;

    public Currencies() {
    }

    public Currencies(BigDecimal currencyId) {
        this.currencyId = currencyId;
    }

    public Currencies(BigDecimal currencyId, String currencyIsoCode, String currencyName) {
        this.currencyId = currencyId;
        this.currencyIsoCode = currencyIsoCode;
        this.currencyName = currencyName;
    }

    public BigDecimal getCurrencyId() {
        return currencyId;
    }

    public void setCurrencyId(BigDecimal currencyId) {
        this.currencyId = currencyId;
    }

    public String getCurrencyIsoCode() {
        return currencyIsoCode;
    }

    public void setCurrencyIsoCode(String currencyIsoCode) {
        this.currencyIsoCode = currencyIsoCode;
    }

    public String getCurrencySign() {
        return currencySign;
    }

    public void setCurrencySign(String currencySign) {
        this.currencySign = currencySign;
    }

    public String getCurrencyName() {
        return currencyName;
    }

    public void setCurrencyName(String currencyName) {
        this.currencyName = currencyName;
    }

    @XmlTransient
    public Collection<Rates> getRatesCollection() {
        return ratesCollection;
    }

    public void setRatesCollection(Collection<Rates> ratesCollection) {
        this.ratesCollection = ratesCollection;
    }

    @XmlTransient
    public Collection<Templates> getTemplatesCollection() {
        return templatesCollection;
    }

    public void setTemplatesCollection(Collection<Templates> templatesCollection) {
        this.templatesCollection = templatesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (currencyId != null ? currencyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Currencies)) {
            return false;
        }
        Currencies other = (Currencies) object;
        if ((this.currencyId == null && other.currencyId != null) || (this.currencyId != null && !this.currencyId.equals(other.currencyId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return currencyName + " " + currencyIsoCode;
    }
    
}
